package com.xtwy.service;

import com.xtwy.dao.UserDao;
import com.xtwy.domain.User;
import com.xtwy.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * @作 者: 侯建军
 * @日 期: 2018/7/29 22:22
 * @描 述:
 * @公 司：山西迅腾伟业
 */
@Service
public class UserService {
    @Autowired
    UserDao userDao;

    public User create(User sysUser) {
        //进行加密
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        sysUser.setPassword(encoder.encode(MD5Util.encode(sysUser.getRawPassword().trim())));
        userDao.create(sysUser);
        return sysUser;
    }

}
